package com.quasar.hpatient.view.adapter;


import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.quasar.hpatient.MainAppliaction;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.medicalmodel.PushinfoData;
import com.quasar.hpatient.network.RetrofitConnection;
import com.quasar.hpatient.utils.MsgJumpView;
import com.quasar.hpatient.view.doctor.DoctorDetailsActivity_;

import java.util.Map;

/**
 * name : lishuai
 * time : 2017/12/7
 * title:
 */

public class MessageAdapter extends BaseQuickAdapter<PushinfoData, BaseViewHolder> {
    public MessageAdapter() {
        super(R.layout.message_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, final PushinfoData item) {

        RoundedImageView friendlist_riv_pic = helper.getView(R.id.friendlist_riv_pic); //头像
        TextView tv_content = helper.getView(R.id.tv_content);  //内容
        TextView Refuse = helper.getView(R.id.Refuse);  //拒绝
        TextView apply = helper.getView(R.id.apply); //同意
        TextView look = helper.getView(R.id.look); //查看
        TextView tv_time = helper.getView(R.id.tv_time);//时间
        TextView tv_time_date=helper.getView(R.id.tv_time_date);//操作时间
        ImageView iv_msg_image=helper.getView(R.id.iv_msg_image);

        if (item != null) {
            if (item.getCover() != null) {
                Glide.with(mContext).load(RetrofitConnection.PHOTOURL + item.getCover()).crossFade().into(friendlist_riv_pic);
            }
            if (item.getMessage() != null) {
                tv_content.setText(item.getMessage());
            }
            if (item.getLogTime() != null) {
                tv_time.setText(item.getLogTime().substring(10, 16));
            }

            if (item.getReceiveType() == 1) {//好友请求
                Refuse.setVisibility(View.VISIBLE);
                apply.setVisibility(View.VISIBLE);
                iv_msg_image.setVisibility(View.GONE);
            } else {
                look.setVisibility(View.VISIBLE);
                apply.setVisibility(View.INVISIBLE);
                iv_msg_image.setVisibility(View.GONE);
            }

            if(item.getStatus()!=0){
                iv_msg_image.setVisibility(View.VISIBLE);
                look.setVisibility(View.INVISIBLE);
            }

            //点击头像跳转
            friendlist_riv_pic.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    DoctorDetailsActivity_.intent(mContext).doctorId(item.getSendId() + "").flags(Intent.FLAG_ACTIVITY_NEW_TASK).start();
                }
            });
            //

            //操作时间
            if(item.getLogTime()!=null){
                tv_time_date.setText(item.getLogTime());
            }

            helper.addOnClickListener(R.id.Refuse);
            helper.addOnClickListener(R.id.apply);
            helper.addOnClickListener(R.id.look);
            helper.addOnClickListener(R.id.list_itease_layout);
        }
    }
}
